package com.giveme5.common.view.ajax;

/**
 * 
 * @author
 * 
 */
public class AjaxUtil {

	public static final int OK = 200;
	public static final int FAIL = 300;

	public static AjaxResult renderOk() {
		return renderOk(null);
	}

	public static AjaxResult renderOkClose(String navTabId) {
		AjaxResult result = renderOk(navTabId);
		result.setCallbackType("closeCurrent");
		return result;
	}

	public static AjaxResult renderOk(String navTabId) {
		AjaxResult result = new AjaxResult();
		result.setStatusCode(OK);
		if (navTabId != null) {
			result.setNavTabId(navTabId);
		}
		return result;
	}

	public static AjaxResult renderFail(String message) {
		AjaxResult result = new AjaxResult();
		result.setMessage(message);
		result.setStatusCode(FAIL);
		return result;
	}

	public static AjaxResult renderFail() {
		return renderFail("");
	}
}
